package com.soilflow.know.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.soilflow.common.domain.KnowsInfo;
import com.soilflow.common.domain.dto.KnowsInfoDto;
import com.soilflow.common.domain.vo.KnowsInfoVo;
import com.soilflow.common.utils.bean.BeanUtils;
import com.soilflow.know.mapper.KnowsInfoMapper;
import com.soilflow.know.service.KnowsInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class KnowsInfoServiceImpl extends ServiceImpl<KnowsInfoMapper, KnowsInfo> implements KnowsInfoService {
    /* 查询【百事通信息】
     *
     * @param id 【百事通信息】主键
     * @return 【百事通信息】
     */
    @Override
    public KnowsInfoVo selectKnowsInfoById(Long id) {
        KnowsInfoVo landInfoVos = this.baseMapper.selectKnowsInfoById(id);
        return landInfoVos;
    }
    /**
     * 查询【百事通信息】列表
     *
     * @param dto 【百事通信息】
     * @return 【百事通信息】集合
     */
    @Override
    public List<KnowsInfoVo> selectKnowsInfoList(KnowsInfoDto dto) {
        List<KnowsInfoVo> landInfoVos = this.baseMapper.selectKnowsInfoList(dto);
        return landInfoVos;
    }
    /**
     * 新增【百事通信息】
     *
     * @param dto 【百事通信息】
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean insertKnowsInfo(KnowsInfoDto dto) {
        boolean save =false;
        KnowsInfo landInfo = new KnowsInfo();
        BeanUtils.copyProperties(dto,landInfo);
        save = this.save(landInfo);
        return save;
    }
    /**
     * 修改【百事通信息】
     *
     * @param dto 【百事通信息】
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateKnowsInfo(KnowsInfoDto dto) {
        boolean save =false;
        KnowsInfo landInfo = new KnowsInfo();
        BeanUtils.copyProperties(dto,landInfo);
        //修改百事通信息
        save = this.updateById(landInfo);
        return save;
    }
    /**
     * 批量删除【百事通信息】
     *
     * @param ids 需要删除的【百事通信息】主键集合
     * @return 结果
     */
    @Override
    public Boolean deleteKnowsInfoByIds(List<Long> ids) {
        return this.removeByIds(ids);
    }
}
